home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-25 | 5.8 KB | 218 lines | [TEXT/MPS ] |
- // Text of project PeoplePicker written on 11/25/95 at 5:03 PM
- // Beginning of text file projectData
- /*
- ** Newton Developer Technical Support Sample Code
- **
- ** PeoplePicker, Demostrates the basic People picker.
- **
- ** by Stephen Harris, Newton Developer Technical Support
- **
- ** Copyright © 1993-1995 by Apple Computer, Inc. All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction. This sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. You are not
- ** permitted to modify and redistribute the source as "DTS Sample Code."
- ** If you are going to re-distribute the source, we require that you
- ** make it clear in the source that the code was descended from
- ** Apple-provided sample code, but that you've made changes.
- */
-
- /*This PeoplePicker demonstrates the basic peoplePicker.
- */
-
-
- constant kAppTitle:= "The People Picker";
-
-
- // constants for the type of people picker
-
- constant kTypePickerArray := '[
- {item: "People", dataClass: |NameRef.People|},
- {item: "Phone numbers", dataClass: |NameRef.Phone|},
- {item: "Fax numbers", dataClass: |NameRef.Fax|},
- {item: "Email addresses", dataClass: |NameRef.email|},
- {item: "Meeting places", dataClass: |NameRef.meetingPlace|},
- ] ;
-
- // End of text file projectData
- // Beginning of file peoplePicker.t
-
- // Before Script for "appBase"
- // ©1993-1995 Apple Computer, Inc. All rights reserved.
-
-
- appBase :=
- {viewBounds: {left: 0, top: 0, right: 240, bottom: 336},
- viewFlags: 1,
- viewFormat: 0,
- declareSelf: 'base,
- title: kAppTitle,
- viewSetupFormScript:
- func()
- begin
- // set up the display
- local b:= GetAppParams();
- self.ViewBounds:= RelBounds(b.appAreaLeft,b.appAreaTop,b.appAreaWidth,b.appAreaHeight);
- end,
- ReorientToScreen:
- func()
- begin
- :syncView();
- :RedoChildren();
- end,
- viewQuitScript:
- func()
- begin
- //memory reclaim project
- peoplePicker.selected:= nil;
- end,
- debug: "appBase",
- viewClass: 74
- };
-
- _view000 :=
- {viewBounds: {left: 0, top: 0, right: 240, bottom: 16}, _proto: @229};
- AddStepForm(appBase, _view000);
-
-
-
- peoplePicker :=
- {viewFlags: 1,
- selected: nil,
- dataClass:
- //set this slot to either nameRef.fax, nameRef.people,nameRef.meetingPlace, or nameRef.email
- '|nameRef.people|,
- viewBounds: {left: 0, top: 30, right: 0, bottom: -55},
- suppressCloseBox: true,
- debug: "peoplePicker",
- viewClass: 74
- };
- AddStepForm(appBase, peoplePicker);
- StepDeclare(appBase, peoplePicker, 'peoplePicker);
-
- // After Script for "peoplePicker"
- thisView := peoplePicker;
- // make the template a peoplePicker
- // NOTE: this is only because the current platform file
- // does not have protoPeoplePicker defined yet
- RemoveSlot(thisView, 'viewClass);
- RemoveSlot(thisView, 'viewFlags);
- thisView._proto:= protoPeoplePicker;
-
-
-
- _view001 :=
- {
- buttonClickScript:
- func()
- begin
- whatSelected:open();
- end,
- text: "What is selected",
- viewBounds: {left: -100, top: 10, right: -10, bottom: 24},
- viewJustify: 8396966,
- _proto: @226
- };
- AddStepForm(appBase, _view001);
-
-
-
- _view002 :=
- {text: " DataClass",
- viewBounds: {left: 10, top: 0, right: 75, bottom: 0},
- viewFlags: 515,
- currentType: 0,
- buttonClickScript:
- func()
- begin
- self.popup := Clone(kTypePickerArray) ;
- popup[currentType] := Clone(popup[currentType]) ;
- popup[currentType].mark := kCheckMarkChar ;
-
- inherited:ButtonClickScript(); // call the inherited version to unhilite the button
- end,
- pickActionScript:
- func(itemSelected)
- begin
- currentType := itemSelected ;
-
- inherited:?pickActionScript(itemSelected); // call the inherited version to unhilite the button
-
- // NOTE: the following code will NOT update the cursor
- // for the listPicker, it will not "filter" out
- // items (e.g. changing to meetingPlace will not remove just people)
-
- peoplePicker:ChangeDataClass(popup[itemSelected].dataClass) ;
- peoplePicker:Update() ;
- end,
- viewJustify: 8401094,
- _proto: @386
- };
- AddStepForm(appBase, _view002);
-
-
-
- _view003 := {_proto: @401};
- AddStepForm(appBase, _view003);
-
-
-
- whatSelected :=
- {viewBounds: {left: -1, top: 72, right: 106, bottom: 188},
- debug: "whatSelected",
- _proto: @180
- };
- AddStepForm(appBase, whatSelected);
- StepDeclare(appBase, whatSelected, 'whatSelected);
-
- _view004 :=
- {
- buttonClickScript:
- func(textIndex)
- begin
- print("selected index " & textIndex);
- end,
- viewBounds: {left: 0, top: 0, right: 0, bottom: 116},
- viewFont: ROM_fontSystem9,
- viewLines: 6,
- viewSetupFormScript:
- func()
- begin
- //call the getSelected fucntion with true to return only the items that are currently selected'
- //note: as items are selected nameRef's are created and put in the selected array. The
- //getSelected function returns an array of the selected items and removes all other nameRef's
-
- local myArray := [];
- foreach item in peoplePicker:getSelected(true) do
- begin
- if item.company then
- AddArraySlot(myArray,(item.company));
- if item.name then
- AddArraySlot(myArray,(item.name.first && item.name.last));
- if item.group then
- AddArraySlot(myArray,(item.group));
- end;
-
- self.listItems := myArray;
- :SetupList();
- end,
- listItems: nil,
- viewJustify: 48,
- viewFormat: 1,
- useScrollers: true,
- _proto: @228
- };
- AddStepForm(whatSelected, _view004);
-
-
-
-
-
-
- constant |layout_peoplePicker.t| := appBase;
- // End of file peoplePicker.t
-
-
-
-